#coding=utf-8

from fetchContent import FetchContent
from Queue import Queue
import threading

lock = threading.RLock()

class DMBJ(threading.Thread):
    
    def __init__(self,threadName,queue):
        threading.Thread.__init__(self,name=threadName)
        self.data = queue
        
    def run(self):
        while not self.data.empty():
            print "ok=%s"%self.getName()
            lineArray = self.data.get().split("$")
            fetchText = FetchContent(lineArray[1], unicode(lineArray[0],'utf8','ignore').encode('gb2312','ignore'))
            fetchText.fetch()

if __name__ == '__main__':
    queue = Queue()
    f = open("c:\\url.txt",'rb')
    list_line = f.readlines()
    f.close()
    for line in list_line:
        queue.put(line)  
    for i in range(10):
        d = DMBJ("dmbj"+str(i), queue)
        d.start()
    print "finish"
